﻿/*===================================================
* CLR版本  : 4.0.30319.42000 
* 类名称   : UI
* 文 件 名 : UI 
* 类描述   :
* 创建人   : oream
* 创建时间 : 2018/3/5 21:52:58
* 修改人   : 
* 修改时间 :
* 版本： @version 1.0
=====================================================*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

namespace Model
{
  [ObjectSystem]
  public class UiSystem : ObjectSystem<UI>, IAwake<UI, GameObject>
  {
    public void Awake(UI t1, GameObject t2)
    {
      this.Get().Awake(t1, t2);
    }
  }
  public class UI : Entity
  {

    public GameObject gameObject;

    public string Name
    {
      get
      {
        return this.gameObject.name;
      }
    }

    public void Awake(UI parentUi, GameObject gameObject)
    {
      if (parentUi != null)
      {
        gameObject.transform.SetParent(parentUi.gameObject.transform, false);
      }
      this.gameObject = gameObject;
    }

    /// <summary>
    /// 设置UI为最上方
    /// </summary>
    public void SetAsFirstSibling()
    {
      this.gameObject.transform.SetAsFirstSibling();
    }


    public override void Dispose()
    {
      if (this.Id == 0) return;
      base.Dispose();
      GameObject.Destroy(this.gameObject);
      this.Parent = null;
    }

  }
}
